﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace SuperX.Common.Collection
{
    /// <summary>
    /// 
    /// </summary>
    public interface IObjCollection : IBasicObject, IJsonSerialize, INotifyPropertyChanged, IDisposable, ICloneable, ICollectionNotify
    {
        /// <summary>
        /// 获得集合下所有名称
        /// </summary>
        /// <returns></returns>
        List<string> GetKeys();

        /// <summary>
        /// 获取集合下所有对象（IBaseObject）
        /// </summary>
        /// <returns></returns>
        List<IBasicObject> GetValues();

        /// <summary>
        /// 根据名称获得对象
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        IBasicObject GetChildObject(string name);

        /// <summary>
        /// this索引获取对象
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        IBasicObject this[string name]
        {
            get;
        }
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IObjCollection<T> : IObjCollection, IBasicObject, IJsonSerialize, INotifyPropertyChanged, IDisposable, ICloneable, ICollectionNotify where T : IBasicObject
    {
        /// <summary>
        /// this索引获取对象
        /// </summary>
        /// <param name="name">名称</param>
        /// <returns></returns>
        new T this[string name]
        {
            get;
        }

        /// <summary>
        /// 获取集合下所有对象（IBaseObject）
        /// </summary>
        /// <returns></returns>
        new List<T> GetValues();

        /// <summary>
        /// 根据名称获得对象
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        new T GetChildObject(string name);
    }


    // 
    public interface ICollectionNotify
    {
        event EventHandler<CollectionChangedArgs> ItemAdded;
        event EventHandler<CollectionChangedArgs> ItemCleared;
        event EventHandler<CollectionChangedArgs> ItemRemoved;
        event EventHandler<CollectionChangedArgs> ItemReplaced;

        void NotifyItemCleared();

        void NotifyItemRemoved(object item);

        void NotifyItemAdded(object item);

        void NotifyItemReplaced(object item);

        string FullName { get; }

        void Add(object item);

        void Clear();

        void Remove(object item);

        void Replace(object item);
    }
}
